package Demo1;

import java.util.Arrays;

public class java2024_5_25 {
//    public static void main(String[] args) {
    //Comparable接口
//        Student student1 = new Student("zhangsan", 18, 66);
//        Student student2 = new Student("lisi", 20, 78);
//        Student student3 = new Student("wangwu", 28, 65);
//        Student student4 = new Student("zhaoliu", 21, 99);
//
//        Student[] students = {student1, student2, student3, student4};
//        Arrays.sort(students);
//        for (int i = 0; i < students.length; i++) {
//            System.out.println(students[i].toString());
//        }

//        for(Student s : students){
//            System.out.println(s.toString());
//        }

//        Arrays.deepToString(students);

//        int[][] array = {
//                {1,2,3,4},
//                {5,6,7,8},
//                {9,10,0},
//        };
//        System.out.println(Arrays.toString(array));
//        Arrays.deepToString()
    //Arrays.deepToString()用来直接输出二维数组的以字符串的形式

//        int[][] array = {
//                {1,2,3,4},
//                {1,2,3},
//                {1,2}
//        };
//        System.out.println(Arrays.deepToString(array));
    //    }
//    public static void main(String[] args) {
    //Comparator接口
//        People people1 = new People("zhangsan",18);
//        People people2 = new People("lisi",24);
//        People people3 = new People("wangwu",28);
//        People people4 = new People("zhaoliu",30);
//
//        People[] peoples = {people1, people2, people3, people4};
//        //要创建该类对象
//        Test test = new Test();
//        Tested tested = new Tested();
//        //将实现了Comparator接口的对象传递进去
//        Arrays.sort(peoples,tested);
//
//        for(People p :peoples){
//            System.out.println(p.toString());
//        }

    //Comparable多用于类创建的实例进行自然排序
    //Comparator多用于不同的排序方式

    //    }
//    public static void main(String[] args) {
        //使用方法实现两数互换
        //使用对象进行交换 - 类比使用指针
//        Demo demo1 = new Demo(10);
//        Demo demo2 = new Demo(20);
//        swap(demo1,demo2);
//        System.out.println(demo1.val);
//        System.out.println(demo2.val);
//    }
//    public static void swap(Demo demo1,Demo demo2){
//        int temp = demo1.val;
//        demo1.val = demo2.val;
//        demo2.val = temp;
//    }

        //使用数组交换数据
//        int[] array = new int[2];
//        array[0] = 10;
//        array[1] = 20;
//        swap(array);
//        System.out.println(Arrays.toString(array));
//
//    }
//
//    public static void swap(int[] array) {
//        int temp = array[0];
//        array[0] = array[1];
//        array[1] = temp;
//    }
        public static void main(String[] args) throws CloneNotSupportedException {
            Animal animal1 = new Animal("coco",2,"black");
            Animal animal2 = (Animal) animal1.clone();
            System.out.println(animal1.toString());
            System.out.println(animal2.toString());

            animal2.inner.number = 0;
            System.out.println(animal1.inner.number);
        }
}
